Saturday, November 24, 2012

Tuesday, October 30, 2012

a contour map for open office calc

I switched from using Excel to Open Office a few years ago. I like the OO package - it works very well and it's free. There is only one problem with it, which has been bugging me for years. There is no way to make a 3D contour map in Calc. There are lots of 2D chart visualizations, and 3D versions of those 2D charts, but no way to display a 3D surface from a table of data. This is something easily implemented in Excel, and a glaring deficiency in Open Office Calc.

However, I still need that functionality. It occurred to me that a 2D map can use color as a representation of a third dimension. The greater the number of colors available, the finer the resolution on that third dimension. A table of data could be searched for the minimum and maximum values, and the difference divided by the number of colors gives a range of values for each color. A second table is then made from the first table, with a color number in place of the original data. Finally, a third table is made from the second table, with a colored square in place of the color number.

This is made possible using the STYLE() and CHOOSE() functions. First, set aside a section of worksheet (or start a new sheet) and change the background colors on a number of cells. I chose to use 32 colors, and arrayed them in a spectrum:

The names of each color is listed; on your worksheet you may want to change the text color to match the background color in each of these 32 cells. The spectrum above isn't perfect, and you might want to switch the colors around a bit or use different colors - just make something that is pleasing to your eye.

Once you have this spectrum, click on a colored cell and then press the F11 key. This will bring up the Styles popup. Create a new Style for each of the cells, and give it a short name (the left column shows the names I chose, C00 through C31). Repeat this for each of the colored cells so you have 32 Styles.

When you have a table you want to display as a color contour map, you need to convert your original data to color numbers. I have 32 colors in my spectrum, so the minimum value on my table gets the color number 0, the maximum value gets color number 31, and the others are in between. I used a linear formula to convert my table values to color numbers, but there is no reason that couldn't be logarithmic or some other conversion formula. It's up to you.

Once the intermediate table of color numbers is generated, the third table of the actual colors is easy. Let's suppose that the top left corner of my color number table is cell BA3, and that I'm putting the top left corner of my contour map at B3. If I just wanted to put color number 0 in that cell, the formula for B3 would be:
= STYLE("C00")
However, I want to choose from one of 32 possible colors. The CHOOSE() function can only choose from up to 30 possibilities, so I needed to trick Calc a little bit. Here's the revised formula for cell B3:
= IF(BA3<16; STYLE(CHOOSE(BA3+1;"C00";"C01";"C02";"C03";"C04";"C05";"C06";"C07";"C08";"C09";"C10";"C11";"C12";"C13";"C14";"C15")); STYLE(CHOOSE(BA3-15;"C16";"C17";"C18";"C19";"C20";"C21";"C22";"C23";"C24";"C25";"C26";"C27";"C28";"C29";"C30";"C31")))

Next, copy and paste this cell across the remainder of the row of the table, then copy and paste that row all the way down the table. Presto! You now have a color contour map of your data in ooCalc.

Thursday, July 19, 2012

Kerbals in Space

Lately I've been obsessing over a unique game, Kerbal Space Program. This game lets you design rockets and launch your creations into orbit around the planet Kerbin, carrying your three brave/foolhardy Kerbal astronauts - Bill, Jeb, and Bob, the Kerman brothers.

What has me so enthralled with this game is the physics engine. Game developer Squad has incorporated very good physics, and this game is a good first-order approximation of orbital mechanics - first-order because it doesn't solve the n-body problem. The game is still in Alpha, and version 0.13.3 is available for free download. There is also an option to pay $15 for the game, in which case you get the most recent version (0.15) and all subsequent updates for free. Each time they update the price goes up, though version 0.13.3 will always be free.

There's more to the game than just building a rocket and getting to orbit. In the free version, it is possible to land on the moon of Kerbin (Mun) and return your kerbonauts home. The paid version features a second moon and spacecraft persistence, allowing multiple objects to be sent into space, forming a moon base and so forth. There are also extensive mods available, some as part of the newer versions and some as part of player-made extensions to the game. Version 0.15 also includes spaceplane parts, for exploring suborbital space.

Friday, May 18, 2012

Beautiful BEAM robot

BEAM robots are a special kind of mobile robot; they have no microprocessor of any kind, only analog electronics such as amplifiers, transistors, resistors, diodes and capacitors. This video shows one of the most elegant designs of a BEAM robot I've ever seen, the W-3 from Mechanical Mutants. (hat tip to Hack a Day)

This is a remarkably robust design. The inner wheel oscillates back and forth around the vertical axis, the outer wheel pivots along an axis on the direction of travel. Simple touch sensors provide feedback influencing turns. The outer wheel also acts as a collision barrier. You can build your own! The circuit diagrams are here.

Monday, April 23, 2012

Alberta provincial election

I live in the beautiful province of Alberta, Canada. Today we are having a provincial election. This is usually a ho-hum affair. In the 107 years Alberta has been a province, only four political parties have formed the government.
The Progressive Conservative party has won a whopping eleven straight majority victories and have governed for an incredible 41 straight years. My prediction is that this string of victories - virtually unheard-of in other longstanding representative democracies - is about to come to a crashing end.

The name of the party, "Progressive Conservative", seems like an oxymoron. It is essentially the marriage of two earlier centrist parties, the Progressives on the center-Left and the much stronger Conservatives on the center-Right. The PCs have governed as a centrist-slightly-Right party for four decades. Over the years the party slowly drifted Left with each passing year. The party made one readjustment back to more conservative values in 1993 to stave off election defeat, and during those early years under Premier Ralph Klein were governing once again from the Right. The period from 1993 to 1999 saw the Province of Alberta completely pay off its debt.

But time moves on and people retire and once again the PC party has slid well over to the left. On the other side, promising to govern from a more Libertarian conservative angle is the Wild Rose party led by Danielle Smith.

You have to admit, it's an amazing advertising gimmick, and news of this bus virally spread as far as Jay Leno.

When I went to vote this afternoon, the ballot boxes were already so full of ballots from earlier voters that there was hardly room for my ballot. Such high voter turnout in a Provincial election bodes poorly for the incumbent - it means people are passionate. We'll see how it goes as the night progresses.

Update: Looks like the polls were all wrong, and the PCs won another majority government.

Wednesday, April 11, 2012

Making your own Google Glass

Recently Google announced Project Glass, and it has already inspired hackers:

(via [hack a day])

There are some obvious pitfalls to this totally immersive computing environment:

This got me thinking, though. The technology required for something like this is largely off-the-shelf, and could be much more capable than Google's project. Goggles with dual video displays (and the optics to focus them) are off the shelf (and come with earbuds for stereo sound). Six degree of freedom head trackers are off the shelf. Webcams and ultrasonic transducers are off the shelf, and can be combined to make something like an Open Source version of Microsoft Kinect which could be mounted on the frame facing forward to monitor the user's hand gestures. The addition of a microphone is trivial - most webcams already have them built in, or a small one could be mounted to the frame of the glasses ahead of the right ear. It is possible to cram in Bluetooth and Wifi and maybe even a cell phone connection.

What I am suggesting is an Open Source project to combine the ideas behind Google Project Glass and Open Kinect and Sixth Sense Computing, to create a device worn like glasses that replaces laptops, tablets, and cell phones, providing a full 3D environment operated by voice command and hand gestures. The technology is available now; why not?

Sunday, March 04, 2012

the Gipper lays it out

The names may have changed, and some of the pressing issues of the day are a little different, but this 1964 speech by Ronald Reagan could just as easily be given today - just add a zero onto any dollar value he mentions.

Tuesday, January 10, 2012

Handy Zombie-Fighting Weapon

When the Zombie Apocalypse arrives, you want to be prepared. A shotgun will get the job done, sure, but to a Zombie horde, a shotgun is like a dinner bell. Whoever made that noise has braaaaainnnsss. Ideally you want a noiseless weapon capable of action either at a distance or close-up. You want a Slingshot Zombiehammer.

(hat tip to Small Dead Animals)